﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using myschoolDal;

namespace school
{
    public partial class stucourseselectioncenter : Form
    {
        private string term;
        private string source;

        public stucourseselectioncenter()
        {
            InitializeComponent();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void stucourseselectioncenter_Load(object sender, EventArgs e)
        {

        }

        private void showsource()
        {
            //清理
            listBox1.ClearSelected();
            foreach (DataRow row in stuservers.StuGetAllSelectSouce(admin.loginId).Tables[0].Rows)
            {
                listBox1.Items.Add(row[0].ToString());
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            term = comboBox1.SelectedItem.ToString();
            dataGridView1.DataSource = stuservers.StuGetAllSelectSouce(term).Tables[0].DefaultView;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox3.Text == "")
            {
                MessageBox.Show("错误：" + bug.Class1.worng4004, "提示");
            }
            else
            {
                source = textBox3.Text.ToString();
                stuservers.StuAddSource(source, term, admin.loginId);
                showsource();
            }
        }
    }
}
